package ray.surface;

import ray.math.Point3;
import ray.math.Ray;
import ray.math.Vector3;
import ray.shader.Shader;

/**
 * Abstract base class for all surfaces.  Provides access for shader and
 * intersection uniformly for all surfaces.
 *
 * @author ags
 */
public abstract class Surface {
	
	/** Shader to be used to shade this surface. */
	protected Shader shader = Shader.DEFAULT_MATERIAL;
	public void setShader(Shader material) { this.shader = material; }
	public Shader getShader() { return shader; }
	
	//This is here so that we don't have cast to Sphere or Box
	//before calculating ray collisions. We should never actually deal with a 
	//generic Surface-ray collision, this function should be overridden in 
	//both Box and Sphere.
	//Returns the "t" (position along the array) value of the nearest intersection, or 
	//0 if there was no collision.
	public double rayCollision(Vector3 direction,Point3 viewPoint){
		assert false;
		return 0;
	}
	
	public double rayCollision(Ray ray){
		return rayCollision(ray.direction,ray.origin);
	}
	
	public Vector3 calcUnitNormal(Point3 point){
		assert false;
		return new Vector3();
	}
	
	
}